<template>
	<uni-popup ref="carOpu" type="center">
		<view class="shop">
			<view class="center" style="color:#666;font-size: 26rpx;">
				<view>数量：x{{orderList.nums}}</view>
				<view style="margin-left:20rpx;">合计蓝宝石：{{orderList.score}}</view>
			</view>
			<view class="list">
				<view class="space-between" style="margin-top:20rpx;" v-for="item in orderList.list">
					<image :src="item.goods_image" mode=""></image>
					<view class="right direction-start" style="justify-content:space-around;">
						<view class="title">{{item.goods_name}}</view>
						<view class="space-between" style="width: 100%;">
							<view class="center"><text style="font-size: 36rpx;">{{item.goods_score}}</text><text
									style="font-size:26rpx;margin-left:10rpx;">蓝宝石</text></view>
							<view>X{{item.nums}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</uni-popup>
</template>

<script setup lang="ts">
	import { ref } from 'vue';
	import { toPublish } from '@mqtt';
	import { getSubscribeCart } from '@/gql/gemstone';
	import { showLoading } from '@/utils/prompt';
	const carOpu = ref(null)
	const orderList = ref()
	function open() {
		carOpu.value.open()
	}
	function init(id : number) {
		showLoading()
		const payload = {
			query: getSubscribeCart,
			variables: {
				subscribe_id: Number(id)
			},
		};
		toPublish(
			'ql/score/getSubscribeCart',
			payload,
			(obj : any) => {
				uni.hideLoading();
				const { getSubscribeCart } = obj.data;
				orderList.value = getSubscribeCart
				open()
			}
		);
	}
	defineExpose({ open, init });
</script>

<style scoped lang="less">
	.shop {
		width: 650rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 20rpx;
		box-sizing: border-box;


		.list {
			width: 100%;
			height: 40vh;
			overflow: auto;

			image {
				width: 130rpx;
				height: 130rpx;
				border-radius: 10rpx;
			}

			.right {
				width: 75%;
				height: 130rpx;

				.title {
					max-width: 100%;
					display: -webkit-box;
					/* autoprefixer: off */
					-webkit-box-orient: vertical;
					/* autoprefixer: on */
					-webkit-line-clamp: 2;
					overflow: hidden;
				}
			}

		}
	}
</style>